#include <stdio.h>
#include <stdlib.h>


// 分区函数，类似快速排序的分区过程
int partition(int arr[], int low, int high) {
    int pivot = arr[high];
    int i = low - 1;
    for (int j = low; j < high; j++) {
        if (arr[j] <= pivot) {
            i++;
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
    }
    int temp = arr[i + 1];
    arr[i + 1] = arr[high];
    arr[high] = temp;
    return i + 1;
}

// 快速排序函数
void quickSort(int arr[], int low, int high) {
    if (low < high) {
        int pivotIndex = partition(arr, low, high);
        quickSort(arr, low, pivotIndex - 1);
        quickSort(arr, pivotIndex + 1, high);
    }
}

int main() {
    int n, k;
    while (scanf("%d %d", &n, &k)!= EOF) {
        int arr[n];
        for (int i = 0; i < n; ++i) {
            scanf("%d",&arr[i]);
        }
        quickSort(arr, 0, n - 1);
        printf("%d\n", arr[k - 1]);
    }
    return 0;
}
